import i18n from '@app-base/common/utils/i18next';
import { ENTITY_TYPE_FACE, NMMeshBaseCommand } from '@app-nextmesh/types';
import { RJSFSchema } from '@rjsf/utils';
import { NameSchema, SelectedEntitiesSchema } from '../jsonSchema';
import CmdControlDialog from './BaseControl';

const ControlType = 'BoundaryLayer';
const schema: RJSFSchema = {
  type: 'object',
  required: ['Name', 'SelectedEntities'],
  properties: {
    ...NameSchema,
    InitLayerHeight: {
      type: 'number',
      title: i18n.t('InitLayerHeight'),
      minimum: 1e-10,
      default: 0.03,
    },
    NLayers: {
      type: 'integer',
      title: i18n.t('NLayers'),
      minimum: 1,
      default: 30,
    },
    GrowthRate: {
      type: 'number',
      title: i18n.t('GrowthRate'),
      minimum: 1,
      default: 1.2,
    },
    DistributionType: {
      type: 'string',
      title: i18n.t('DistributionType'),
      default: 'Separation',
      oneOf: [
        {
          type: 'string',
          title: i18n.t('Separation'),
          const: 'Separation',
        },
      ],
    },
    ...SelectedEntitiesSchema,
  },
};
export const cmdBoundaryLayer: NMMeshBaseCommand = {
  id: 'cmdBoundaryLayer',
  label: 'command.mesh.boundaryLayer',
  icon: 'commands/simu/boundaryLayer',
  create: (label, onClose, _, customParams) => (
    <CmdControlDialog
      title={i18n.t(label)}
      onClose={onClose}
      params={customParams}
      pickTypes={[ENTITY_TYPE_FACE]}
      controlType={ControlType}
      schema={schema}
    />
  ),
};
